package com.party.core.service.audio.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.audio.AudioReadDao;
import com.party.core.dao.write.audio.AudioWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.audio.Audio;
import com.party.core.service.audio.IAudioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party
 * @description: 音频業務實現
 * @author: Hua Qunhao
 * @create: 2019-03-11 15:10
 **/
@Service("AudioService")
public class AudioService implements IAudioService {

    @Autowired
    private AudioReadDao audioReadDao;
    @Autowired
    private AudioWriteDao audioWriteDao;

    @Override
    public String insert(Audio audio) {
        BaseModel.preInsert(audio);
        boolean result = audioWriteDao.insert(audio);
        if (result){
            return audio.getId();
        }
        return null;
    }

    @Override
    public boolean update(Audio audio) {
        audio.setUpdateDate(new Date());
        return audioWriteDao.update(audio);
    }

    @Override
    public boolean deleteLogic(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return audioWriteDao.deleteLogic(id);
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return audioWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public Audio get(String id) {
        return audioReadDao.get(id);
    }

    @Override
    public List<Audio> listPage(Audio audio, Page page) {
        return audioReadDao.listPage(audio,page);
    }

    @Override
    public List<Audio> list(Audio audio) {
        return audioReadDao.listPage(audio,null);
    }

    @Override
    public List<Audio> batchList(Set<String> ids, Audio audio, Page page) {
        return null;
    }

    @Override
    public List<Audio> webListPage(Audio audio, Map<String, Object> params, Page page) {
        return audioReadDao.webListPage(audio,params,page);
    }

    @Override
    public List<Audio> findAudio(Audio audio) {
        return audioReadDao.findAudio(audio);
    }

    @Override
    public Audio findAudioByEventId(String eventId) {
        return audioReadDao.findAudioByEventId(eventId);
    }
}
